home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / t_os / gpen32k / source.exe / LIB / OSRC / TIFFSAVE.C < prev    next >
C/C++ Source or Header  |  1993-08-04  |  949b  |  54 lines

  1. /*    Tiff File saver    */
  2.  
  3. #include    <stdio.h>
  4. #include    <stdlib.h>
  5. #include    <egb.h>
  6. #include    <tifflib.h>
  7. #include    <okome.h>
  8. #include    <normlib.h>
  9.  
  10. extern char b[];
  11.  
  12. static xx, xx2, yy;
  13. static FILE *fp;
  14.  
  15. int tifo( char *buf, long sz )
  16. {
  17.     fwrite(buf, 1, sz, fp);
  18.     return (0);
  19. }
  20.  
  21. int tifgv( char *buf, int ofs, int lines)
  22. {
  23.     egbget(xx,yy+ofs,xx2,yy+ofs+lines-1,buf);
  24.     return (0);
  25. }
  26.  
  27. int tiffsave( char *na, int x1, int y1, int x2, int y2, int z, int p )
  28. {
  29.     char im[2048], fo[4096], hd[4096];
  30.     int x4, i;
  31.     x4 = x2-x1+1;
  32.     xx = x1;
  33.     xx2 = x2;
  34.     yy = y1;
  35.     if ((fp = fopen(na,"wb"))==NULL)
  36.         return (-1);
  37.     fseek(fp,512,SEEK_SET);
  38.     TIFF_setSaveFunc(tifo,tifgv);
  39.     if (z==0)
  40.     {
  41.         z = 1;
  42.     }    else    {
  43.         z = 5;
  44.     }
  45.     i = TIFF_saveImage(16,x4,y2-y1+1, z, fo, 4096,im,x4,1024/x4,b);
  46.     fseek(fp,0,SEEK_SET);
  47.     if (z==1)
  48.     {    i = 0;    }
  49.     TIFF_setHead(hd, 16, x4, y2-y1+1, i, im);
  50.     fwrite(hd, 1,512,fp);
  51.     fclose(fp);
  52.     return (0);
  53. }
  54.